package threading;

public class ThreadDemo9Wait {
    public static void main(String[] args) throws InterruptedException {
        Object locker = new Object();
        Thread t1 = new Thread( () -> {
                try {
                    System.out.println("wait,开始");
                    synchronized (locker) {
                        locker.wait();
                    }
                    System.out.println("wait,结束");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
        });

        t1.start();  //启动线程
        Thread.sleep(1000);

        Thread t2 = new Thread( () -> {
            System.out.println("notify,开始");
            synchronized (locker) {
                locker.notify();
            }
            System.out.println("notify,结束");
        });
        t2.start();
    }
}
